package se.sics.tac.aw;

import static org.junit.Assert.*;

import org.junit.Test;
import java.util.Vector;

public class InsertionSortTest {

	@Test
	public void testInsertionSortIntArrayInt() {
		int[] list = new int[]{5,10,6,8,5};
		
		list = InsertionSort.insertionSort(list, list.length);
		
		assertEquals("Index 0", 5, list[0]);
		assertEquals("Index 1", 5, list[1]);
		assertEquals("Index 2", 6, list[2]);
		assertEquals("Index 3", 8, list[3]);
		assertEquals("Index 4", 10, list[4]);
	}

	@Test
	public void testSortAscendingVectorOfFloat() {
		Vector<Float> list = new Vector<Float>();
		list.add(5f);
		list.add(10f);
		list.add(6f);
		list.add(8f);
		list.add(5f);
		
		list = InsertionSort.sortAscending(list);
		
		assertEquals("Index 0", 5f, list.get(0));
		assertEquals("Index 1", 5f, list.get(1));
		assertEquals("Index 2", 6f, list.get(2));
		assertEquals("Index 3", 8f, list.get(3));
		assertEquals("Index 4", 10f, list.get(4));
	}

	@Test
	public void testSortDescendingVectorOfFloat() {
		Vector<Float> list = new Vector<Float>();
		list.add(5f);
		list.add(10f);
		list.add(6f);
		list.add(8f);
		list.add(5f);
		
		list = InsertionSort.sortDescending(list);
		
		assertEquals("Index 0", 10f, list.get(0));
		assertEquals("Index 1", 8f, list.get(1));
		assertEquals("Index 2", 6f, list.get(2));
		assertEquals("Index 3", 5f, list.get(3));
		assertEquals("Index 4", 5f, list.get(4));
	}
}
